<?php

class Country_Model_Voteoption extends Core_Model_Item_Abstract
{
  
  public function getTitle()
  {
    return $this->title;
  }
  public function getVoteResult($country_id){
  	 $voteResultsTable = Engine_Api::_()->getDbtable('voteresults','country');
     $select = $voteResultsTable->select()
     		   ->where('voteoption_id = ?', $this->voteoption_id)
     		   ->where('country_id = ?', $country_id);
     return $voteResultsTable->fetchRow($select);
  }
  public function voteHistory($country_id){
  	 $viewer = Engine_Api::_()->user()->getViewer();
        $user_id = $viewer->getIdentity();
  	 $votetable = Engine_Api::_()->getDbtable('vote', 'country');
    	$selectv = $votetable->select()
          				->where('voteoption_id = ?', $this->voteoption_id)
          			    ->where('country_id = ?', $country_id)
          				->where('user_id = ?', $user_id);
          	$voteData = $votetable->fetchRow($selectv);
	
     if($voteData) return $voteData->is_like;
     else return 2;   	
  }
}